/**
 * @author Antonio G. Zippo
 */

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Input {
    int size;
    int dimension;
    ArrayList<CharSequence> cs;
    
    public Input(Collection<int[][]> o,int level)
    {
        this.size = o.size();
        Iterator<int[][]> iter = o.iterator();
        this.cs = new ArrayList();
        while(iter.hasNext())
        {
            this.cs.add(discretize(iter.next(),level));
        }
    }
    
    public static CharSequence discretize(int img[][], int level)
    {
        final int len = img.length;
	String ds = "";
	int l;
	for(int i=0; i < len; i++)
	{
            for(int j = 0; j < len; j++)
            {
                l = -1;
		for(int k = 0; k <= img[i][j] ; k += 256/level)
		{	
                    l = l+1;//System.out.println(l);
                }
		//System.out.println("out: " + l);
		ds += (new Integer(l)).toString();	
            }
	}
	//System.out.println(ds);
	return ds;
    }
    
    public ArrayList<CharSequence> getData()
    {
        return this.cs;
    }
    
    public int getSize()
    {
        return this.size;
    }
    
    public int getDimensionality()
    {
        return this.dimension;
    }
    
    @Override
    public String toString()
    {
        String out = "";
        for(int i = 0; i < this.size; i++)
        {
            out += this.cs.get(i) + "\n";
        }
        return out;
    }
    
    public static String type(Object obj) 
    {
        return obj.getClass().getName(); 
    }
}
